package com.wisely.xxboot.security;

import com.wisely.xxboot.dao.SecuritySysUserRepository;
import com.wisely.xxboot.domain.SecuritySysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c) 2017</p>
 * <p>Company: 中视数讯</p>
 * <p>Site: www.digi-zones.com</p>
 *
 * @author shengping
 * @version 1.0
 * @date 2017/7/3
 */
public class CustomUserService implements UserDetailsService { //1
    @Autowired
    SecuritySysUserRepository securitySysUserRepository;
    @Override
    public UserDetails loadUserByUsername(String username){ //2
        SecuritySysUser user = securitySysUserRepository.findByUsername(username);
        if(user==null){
            throw new UsernameNotFoundException("用户名不存在！");
        }
        return user;

    }
}
